package com.quectel.sdk.simulation.monitor;

import com.fasterxml.jackson.core.type.TypeReference;
import com.quectel.sdk.ex.simulation.QueryDeviceException;
import com.quectel.sdk.simulation.SimulationBaseClient;
import com.quectel.sdk.simulation.basemodel.SimulationDevice;
import com.quectel.util.common.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 在这里编写说明
 *
 * @author: rananxin
 * @email: ryan.ran@quectel.com
 * @date: 2022-10-19 11:01:00
 */
public class MonitorClient extends SimulationBaseClient {

    private static final Logger LOGGER = LoggerFactory.getLogger(MonitorClient.class);

    /**
     * 获取摄像头设备
     *
     * @return
     */
    public List<SimulationDevice> getMonitors() {
        String apiPath = "/device/queryByDeviceTypeCode";
        Map<String, Object> params = new HashMap<>();
        params.put("deviceTypeCode", "SimulationMonitor");
        Response<List<SimulationDevice>> response = requester.post(apiPath, params, new TypeReference<Response<List<SimulationDevice>>>() {
        });
        if (response.isSuccess()) {
            return response.getData();
        }
        throw new QueryDeviceException("Obtain device failed");


    }

    /**
     * 获取流地址
     *
     * @return
     */
    public List<String> getStreamUrls(List<String> uniqueIds) {
        String apiPath = "/monitor/getStreamUrls";
        Response<List<String>> response = requester.post(apiPath, uniqueIds, new TypeReference<Response<List<String>>>() {
        });
        if (response.isSuccess()) {
            return response.getData();
        }
        throw new QueryDeviceException("Obtain device stream url failed");


    }

}
